package com.example.qa.service.domain;

import com.example.qa.service.common.demos.web.IdWorker;
import com.example.qa.service.domain.port.DeleteAllQasPort;
import com.example.qa.service.domain.port.GetQaListPort;
import com.example.qa.service.domain.valueobject.Answer;
import com.example.qa.service.domain.valueobject.QaId;
import com.example.qa.service.domain.valueobject.Question;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

@Setter
@Getter
@ToString
public class Qa {
    private QaId id;
    private Question question;
    private Answer answer;

    public Qa() {
    }

    public Qa(Answer answer, QaId id, Question question) {
        this.answer = answer;
        this.id = id;
        this.question = question;
    }

    public Qa(Question question, Answer answer) {
        this.id = this.genId();
        this.question = question;
        this.answer = answer;
    }
    public QaId genId(){
        return new QaId(new IdWorker().nextId());
    }

    public static List<Qa> getQas(GetQaListPort getQaListPort) {
        return getQaListPort.getQas();
    }
    public static void deleteAllQas(DeleteAllQasPort deleteAllQasPort) {
        deleteAllQasPort.deleteAllQas();
    }
}
